﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace ERF.Input
{
    /// <summary>
    /// Represents an button on a gamepad.
    /// </summary>
    public class AssignedGamepadButton : AssignedButton
    {
        private Buttons button;

        public AssignedGamepadButton(InputHandler handler, Buttons button) : base(handler)
        {
            this.button = button;
        }

        /// <summary>
        /// Returns a boolean denoting if the button is currently being pressed or not.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonDown() {
            return handler.GamepadState.IsButtonDown((Buttons)button);
        }

        /// <summary>
        /// Returns a boolean denoting if the button has just been released.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonReleased()
        {
            return handler.OldGamepadState.IsButtonDown((Buttons)button) && handler.GamepadState.IsButtonUp((Buttons)button);
        }
    }
}
